<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<title>退货订单明细</title>
<%@ include file="/WEB-INF/component/commonCSS.jsp"%>
<!--[if lt IE 9]>
        <script src="lib/js/html5shiv.min.js"></script>
        <script src="lib/js/respond.min.js"></script>
    <![endif]-->
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
	<input type="hidden" id="typeflag" value='null'>
	<section class="content-header">
	<h1>退货单详情</h1>
	<ol class="breadcrumb">
		<li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
		<li class="active"><a href="#">商品退货</a></li>
		<li class="active"><a href="#">已确认退货单</a></li>
	</ol>
	</section>

	<section class="content">
	<div class=" box box-success">
		<div class="box-body">
			<form class=" form-inline" id='form'>
				
				
				<div class="form-group form-group-xs">
					退货日期： <input class="form-control" type="text"  name="submitStartDatetime" id="submitStartDatetime"
						  dateFmt="yyyy-MM-dd" onFocus="var endDate=$dp.$('submitEndDatetime');WdatePicker({maxDate:'#F{$dp.$D(\'submitEndDatetime\')}'})"/>
						  <label>-</label>&nbsp;&nbsp;<input class="form-control" type="text" name="submitEndDatetime" id ="submitEndDatetime"
						dateFmt="yyyy-MM-dd" onFocus="WdatePicker({minDate:'#F{$dp.$D(\'submitStartDatetime\')}'})"/>
				</div>
					
				<div class="form-group form-group-xs">
					药品编码： <input class="form-control" type="text" name="drugCode"
						placeholder="药品编码" />
				</div>
				<div class="form-group form-group-xs">
					通用名： <input class="form-control" type="text" name="drugName"
						placeholder="通用名" />
				</div>
				<div class="form-group form-group-xs">
					生产企业： <input class="form-control" type="text" name="prodComp"
						placeholder="生产企业" />
				</div>
				<input hidden="true" name="retCode" value="${param.retCode}"/>
				<button type="button" class="btn btn-success btn-sm" >查 询</button>
			</form>
		</div>
	</div>
	<table class="jqgrid" id="gridlist"></table>
	<div id="gridpage"></div>
	<div class="box box-warning bottongroup">
             <a href="${ctx }/purReturnOldOrder/toReturnOldOrderByHospList.html" class="btn btn-default btn-sm">返 回</a>
        </div>
	</section>
	<%@ include file="/WEB-INF/component/commonJS.jsp"%>
	<script type="text/javascript">
		$(function() {
		var date = new Date();
        date.setMonth(date.getMonth() - 1);
        $('#submitStartDatetime').val(date.format("yyyy-MM-dd"));
        $('#submitEndDatetime').val(new Date().format("yyyy-MM-dd"));
			var postJson = formatForm("form");
			$("#gridlist").jqGrid(
					{   url : "getReturnOldOrderList.html",
						mtype : "POST",
						datatype : "json",
						postData:postJson,
						autowidth : true,
						shrinkToFit : false,
						height : 290,
						colNames : [ '退货明细编号','退货价格','退货数量','金额','退货原因','医疗机构',"医疗机构地区",'配送企业名称','药品编码 ','通用名 ','剂型 ','规格 ','转换系数 ','单位 ','材质 ','生产企业 ','退货时间','退货单号'],
						colModel : [{name : 'retDetailCode',index : 'sdate',width : 210, sortable: false, align : "center"	
									},
									{name : 'proPrice',index : 'sdate',width : 70, sortable: false, align : "right",
					                 	   formatter:function(cellvalue, options, row){
					                           return formatAmount(cellvalue, options, row);
					                       }},
									{name : 'retCount',index : 'sdate',width : 60, sortable: false, align : "center"},
									{name : 'retTotlePrice',index : 'sdate',width : 80, sortable: false, align : "right"},
									{name : 'retReason',index : 'sdate',width : 100, sortable: false, align : "center"},
									{name : 'hospName',index : 'sdate',width : 160, sortable: false, align : "left",
										formatter:function(cellvalue, options, row){
											if (cellvalue != null){
				                    		 return "<a href=\"javascript:$.HN.dialog.opendialog('"+row.hospName+"','医疗机构详情','stdHospInfo/hospInfoDetail.html?hospId="+row.hospId+"','800px','400px',function operResult(val){return operResult;})\">"+cellvalue+"</a>";
											}
											return "";
										}
									}, 
									{name : 'areaName',index : 'arFullname',width : 100, sortable: false, align : "center"},
									{name : 'compName',index : 'ship',width : 180, sortable: false, align : "left",
										 formatter:function(cellvalue, options,row) {
											 if (cellvalue != null){
												 return "<a href=\"javascript:$.HN.dialog.opendialog('"+row.compId+"','"+cellvalue+"','${ctx}/stdCompinfo/toStdCompinfoDetail.html?compId="+row.compId+"','800px','400px',function operResult(val){return operResult;})\">"+cellvalue+"</a>";
											 }
											 return "";
							     		}
									},
									{name : 'drugCode',index : 'stock',width :120, sortable: false, align : "center",
										formatter:function(cellvalue, options, row) {
											if (cellvalue != null){
											   return "<a href=\"javascript:$.HN.dialog.opendialog('"+row.drugId+"','"+cellvalue+"','${ctx}/stdDrug/drugInfoDetail.html?drugId="+row.drugId+"','800px','400px',function operResult(val){return operResult;})\">"+cellvalue+"</a>";
									  		}
											return "";
										}
									}, 
									{name : 'drugName',index : 'drugName',width : 140, sortable: false, align : "left"},
									{name : 'formName',index : 'formName',width : 80, sortable: false, align : "center"},
									{name : 'specName',index : 'specName',width : 80, sortable: false, align : "left"},
									{name : 'factor',index : 'factor',width : 80, sortable: false, align : "center"},
									{name : 'unit',index : 'unit',width : 40, sortable: false, align : "center"}, 
									{name : 'materialName',index : 'materialName',width : 80, sortable: false, align : "left"}, 
									{name : 'prodComp',index : 'prodComp',width : 180, sortable: false, align : "left",
										 formatter:function(cellvalue, options,row) {
											 if (cellvalue != null){
											 return "<a href=\"javascript:$.HN.dialog.opendialog('"+row.prodCompId+"','"+cellvalue+"','${ctx}/stdCompinfo/toStdCompinfoDetail.html?compId="+row.prodCompId+"','800px','400px',function operResult(val){return operResult;})\">"+cellvalue+"</a>";
											 }
											 return "";
											}
									},
									{name : 'submitTime',index : 'ship',width : 140, sortable: false, align : "center"},
									{name : 'retCode',index : 'ship',width : 180, sortable: false, align : "center"}
									
						],
						rowNum : 20,
						rowList : [ 10, 20,50,100],
						rownumbers : true,
						pager : "#gridpage",
						//multiselect: true, 
						viewrecords : true,
						caption : "${param.retCode}/${delCompName}",
						jsonReader : {
							repeatitems : false,
							id : "ids"
						}
					});
			$("#area1").HNSelect({
                url: "${ctx}/selectController/getArea.html", 
                data: { ID: '${sysAreaId}' }, 
                defaultText: "<option value=''>请选择</option>",
                defaultselect: "",
                func: function () {
                    $("#area2").HNSelect({
                        parent_selector: "#area1", 
                        url: "${ctx}/selectController/getArea.html", 
                        dataid: "ID", 
                        defaultText: "<option value=''>请选择</option>",
                        defaultselect: ""
                    });
                }
            });
			$("#gridlist").jqGrid('navGrid', '#gridpage', {add : false,edit : false,del : false,search : false,refresh : false});
			$(window).trigger("resize");
			
			   /*按条件查询*/
			   $('.btn-success').click(function(){
					   var postJson = formatForm("form");
					   var strat = new Date( postJson['submitStartDatetime'].replace(/-/g,"/") );
					   var End = new Date( postJson['submitEndDatetime'].replace(/-/g,"/") );
					  //起始日期大于截至日期的判断
					   if (strat > End) {
						 var temp =postJson['submitStartDatetime'];
						 postJson['submitStartDatetime'] = postJson['submitEndDatetime'];
						 postJson['submitEndDatetime']= temp;
						 $("[name='submitStartDatetime']").val($("[name='submitEndDatetime']").val());
						 $("[name='submitEndDatetime']").val(temp);
						 temp=null;
					   }
			                $("#gridlist").jqGrid("clearGridData");
			                $("#gridlist").jqGrid('setGridParam',{  
			                mtype: "POST",
			                datatype:'json',
			                postData:postJson,
			                page : 1
			            }).trigger("reloadGrid"); 
			   });
		});
	</script>
</body>
</html>